/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControllerLag;
import ModelLag.*;
import DBLag.*;
import java.util.ArrayList;

/**
 * Controllerklasse for Lane.
 * @author DM75 Gruppe 3
 * @version 2011-12-22
 */
public class LockerCTR {
        private IFDbLocker dbLocker;

        public LockerCTR()
    {
        dbLocker = new DbLocker();
    }
    
        /**
         * Finder Locker via LockerID
         * @param lockerID
         * @return
         */
        public Locker findLocker(int lockerID)
    {
        return dbLocker.findLocker(lockerID);
    }
    
    
    /**
     * Opretter en Locker via lockerID, avabliable, depositum, pricePrYear,amountOfKeys og lockerType
     * @param lockerID
     * @param avaliable
     * @param depositum
     * @param pricePrYear
     * @param amountOfKeys
     * @param lockerType
     * @return
     */
    public int createLocker(int lockerID, int avaliable, double depositum, double pricePrYear, int amountOfKeys, String lockerType)
    {
        Locker lockerObj = new Locker(lockerID, avaliable, depositum, pricePrYear, amountOfKeys, lockerType);
        return dbLocker.insertLocker(lockerObj);
    }
    
    /**
     * Opdatering af en locker
     * @param lockerID
     * @param avaliable
     * @param depositum
     * @param pricePrYear
     * @param amountOfKeys
     * @param lockerType
     * @return
     */
    public int updateLocker(int lockerID, int avaliable, double depositum, double pricePrYear, int amountOfKeys, String lockerType)
    {
      
        Locker lockerObj = new Locker();
        lockerObj.setLockerID(lockerID);
        lockerObj.setAvailable(avaliable);
        lockerObj.setDepositum(depositum);
        lockerObj.setPricePrYear(pricePrYear);
        lockerObj.setAmountOfKeys(amountOfKeys);
        lockerObj.setLockerType(lockerType);
        
        return dbLocker.updateLocker(lockerObj);
    }
    
    /**
     * Sletning af et locker
     * @param lockerID
     * @return
     */
    public int deleteLocker(int lockerID)
    {
        return dbLocker.deleteLocker(lockerID);
    }
    
    /**
     * Henter alle lockers som findes
     * @return
     */
    public ArrayList<Locker> getAllLockers()
    {
        return dbLocker.getAllLockers();
    }
    
}